package com.sample.rx;

import android.util.Log;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.loyal.rx.RxPermission;
import com.sample.rx.base.BasicActivity;

import java.util.List;

import butterknife.ButterKnife;

public abstract class BaseActivity extends BasicActivity implements RxPermission.SingleCallback, RxPermission.MultipleCallback {
    private RxPermission permission;

    @Override
    public void bindViews() {
        if (null == permission)
            permission = RxPermission.getInstance();
        ButterKnife.bind(this);
    }

    /**
     * 用于单项权限申请
     */
    public void singlePermission(int code, String... permissions) {
        Log.e("singlePermission: ", "" + (permission.hashCode()));
        if (null == permission)
            return;
        permission.with(this).single(code, this, permissions);
    }

    public void multiplePermissions(String... permissions) {
        if (null == permission)
            return;
        permission.with(this).multiple(this, permissions);
    }

    @Override
    public void onSingleCallback(int code, boolean b, Throwable throwable) {

    }

    @Override
    public void onMultipleCallback(@NonNull List<String> list,
                                   @NonNull List<String> list1,
                                   @Nullable Throwable throwable) {

    }
}